<div id="replace_event"></div>
<table class="full">
	<tr><td><?= "<a href='javascript:;' onClick=\"
	
	$.ajax({
	  url: '" . base_url() . "calendar/full/" . date("n",$date) . "/" . date("Y",strtotime("-1 year",$date)) . "/cal_only/',
	  cache: true,
	  success: function(html){
	    $('#full_calendar').html(html);
	  }
	});
	
	
	\"><<</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:;' onClick=\"
	
	$.ajax({
	  url: '" . base_url() . "calendar/full/" . date("n",strtotime("-1 month",$date)) . "/" . date("Y",strtotime("-1 month",$date)) . "/cal_only/',
	  cache: true,
	  success: function(html){
	    $('#full_calendar').html(html);
	  }
	});
	
	\"><</a></td><td colspan='5'>" . date("F Y",$date) . "</td><td><a href='javascript:;' onClick=\"
	
	$.ajax({
	  url: '" . base_url() . "calendar/full/" . date("n",strtotime("+1 month",$date)) . "/" . date("Y",strtotime("+1 month",$date)) . "/cal_only/',
	  cache: true,
	  success: function(html){
	    $('#full_calendar').html(html);
	  }
	});
	
	\">></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:;' onClick=\"
	
	$.ajax({
	  url: '" . base_url() . "calendar/full/" . date("n",$date) . "/" . date("Y",strtotime("+1 year",$date)) . "/cal_only/',
	  cache: true,
	  success: function(html){
	    $('#full_calendar').html(html);
	  }
	});
	
	\">>></a></td</tr>";?>
	<tr><th>Sunday</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th></tr>
		<?php
		foreach ($dates as $date) { 
			echo "<tr>";
			for ($i=0;$i<7;$i++) {
				echo "<td><div class='containerr'><div class='date'>$date[$i]</div>";
				if(isset($events)){
				if(array_key_exists($date[$i],$events)){
					foreach($events[$date[$i]] as $current){
						$a = (strtotime("$current[end]") - strtotime("$current[start]"))/(60*60*24);
						if($a<1) echo "<a href='javascript:;' onClick=\"
						
						$.ajax({
						  url: '" . base_url() . "calendar/event/" . $current['id'] . "',
						  cache: true,
						  success: function(html){
						    $('#replace_event').html(html);
						  }
						});
						
						\"><div class='event'>" . date("g:ia",strtotime("$current[start]")) . " " . $current['name'] . "</div></a><br>";
						else{
							if($date[$i]==date("j",strtotime("$current[start]"))) echo "<a href='javascript:;' onClick=\"
							
							$.ajax({
							  url: '" . base_url() . "calendar/event/" . $current['id'] . "',
							  cache: true,
							  success: function(html){
							    $('#replace_event').html(html);
							  }
							});
							
							\"><div class='event'>" . date("g:ia",strtotime("$current[start]")) . " " . $current['name'] . "</div></a><br>";
							else echo "<a href='javascript:;' onClick=\"
							
							$.ajax({
							  url: '" . base_url() . "calendar/event/" . $current['id'] . "',
							  cache: true,
							  success: function(html){
							    $('#replace_event').html(html);
							  }
							});
							
							\"><div class='event'>$current[name]</div></a><br>";
						}
					}
					echo "</div></td>";
					
				}
				else{
					echo"</div></td>";
				}
			}
			else{
				echo "</div></td>";
			}	
			}
			echo "</tr>";
		}
		?>
</table>
</div>
